/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.widgets;

import TimeRecording.enums.HolidayGrantType;
import TimeRecording.enums.PartOfDay;
import java.util.Arrays;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

/**
 *
 * @author dpatchett
 */
public class HolidayGrantTypeComboBox extends JComboBox {

    // List is shared by all models/combos (cannot share a single model)

    private static List<HolidayGrantType> list;

    private static class HolidayGrantTypeComboModel extends DefaultComboBoxModel {

        public HolidayGrantTypeComboModel() {
            super();
            if (list == null) {
                list = Arrays.asList(HolidayGrantType.values());
            }
        }

        @Override
        public Object getElementAt(int index) {
            return list.get(index);
        }

        @Override
        public int getSize() {
            return list.size();
        }
    }

    public HolidayGrantTypeComboBox() {
        super();
        this.setModel(new HolidayGrantTypeComboModel());
    }
}
